package cn.iune.web.security.filters;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;

//自定义过滤器
//@WebFilter(filterName="/testFilter",urlPatterns="/filter/*")
public class TestFilter implements Filter {

    
    @Override  
    public void init(FilterConfig filterConfig) throws ServletException {  
        System.out.println("*****************TestFilter init-----------filter");  
    } 

	@Override
	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws ServletException, IOException  {
		// TODO Auto-generated method stub
		/*
		HttpServletRequest httpRequest = (HttpServletRequest)req;
//		httpRequest.getSession().setMaxInactiveInterval(1);
		System.out.println("--------------------------------------------------------------------------------------------");
		System.out.println("httpRequest.getAuthType()-->"+httpRequest.getAuthType());
		System.out.println("httpRequest.getMethod()-->"+httpRequest.getMethod());
		System.out.println("httpRequest.getHeader('USER-AGENT')-->"+httpRequest.getHeader("USER-AGENT").toLowerCase());
		System.out.println("httpRequest.getPathInfo()-->"+httpRequest.getPathInfo());
		System.out.println("httpRequest.getPathTranslated()-->"+httpRequest.getPathTranslated());
		System.out.println("httpRequest.getQueryString()-->"+httpRequest.getQueryString());
		System.out.println("httpRequest.getRemoteUser()-->"+httpRequest.getRemoteUser());
		System.out.println("httpRequest.getRequestedSessionId()-->"+httpRequest.getRequestedSessionId());
		System.out.println("httpRequest.getRequestURI()-->"+httpRequest.getRequestURI());
		System.out.println("httpRequest.getRequestURL()-->"+httpRequest.getRequestURL());
		
		String auth_token = null;
//		System.out.println("httpRequest.getHeaderNames()-->"+httpRequest.getHeaderNames());
		Enumeration paraNames1=httpRequest.getHeaderNames();
		for(Enumeration e=paraNames1;e.hasMoreElements();){
		 
		       String thisName=e.nextElement().toString();
		       String thisValue=httpRequest.getHeader(thisName);
		       System.out.println(thisName+"--------------"+thisValue);
		       if("auth_token".equals(thisName)){
		    	   auth_token = thisValue;
		       }
		}
		
		System.out.println("PlatformJwtFilter--token-->"+auth_token);
		System.out.println("--------------------------------------------------------------------------------------------");
		*/
        chain.doFilter(req, res);  
        
	}

	
	@Override
	public void destroy() {
		// TODO Auto-generated method stub
	}
			
}
